﻿using AutoMapper;
using BCDto.Sim.Admin.AdminPermissionConfig;
using BCDto.Sim.Admin.AdminPermissionMappingPage;
using BCDto.Sim.Admin.AdminPermissionRecord;
using BCDto.Sim.Admin.AdminSpecificPermission;
using BCDto.Sim.Admin.AdminSpecificPermissionRecord;
using BCDto.Sim.Admin.TreePermission;
using BCEntity.Sim.Admin.AdminPermissionConfig;
using BCEntity.Sim.Admin.AdminPermissionMappingPage;
using BCEntity.Sim.Admin.AdminPermissionRecord;
using BCEntity.Sim.Admin.AdminSpecificPermission;
using BCEntity.Sim.Admin.AdminSpecificPermissionRecord;
using System;
using System.Collections.Generic;
using System.Text;

namespace BCService.MapperProfiles.Sim.Admin.AdminPermission
{
    public class AdminPermissionProfile : Profile
    {
        public AdminPermissionProfile()
        {
            //管理员特殊权限配置
            CreateMap<AdminSpecificPermissionDto, AdminSpecificPermissionEntity>().IgnoreAllPropertiesWithAnInaccessibleSetter();
            CreateMap<AdminSpecificPermissionRequestDto, AdminSpecificPermissionPutDto>().IgnoreAllPropertiesWithAnInaccessibleSetter();
            CreateMap<AdminSpecificPermissionRequestDto, AdminSpecificPermissionEntity>().IgnoreAllPropertiesWithAnInaccessibleSetter();
            CreateMap<AdminSpecificPermissionPutDto, AdminSpecificPermissionEntity>().IgnoreAllPropertiesWithAnInaccessibleSetter();
            CreateMap<AdminSpecificPermissionEntity, AdminSpecificPermissionDto>().IgnoreAllPropertiesWithAnInaccessibleSetter();
            
            //管理员特殊权限记录
            CreateMap<AdminSpecificPermissionRecordDto, AdminSpecificPermissionRecordEntity>().IgnoreAllPropertiesWithAnInaccessibleSetter();
            CreateMap<AdminSpecificPermissionRecordRequestDto, AdminSpecificPermissionRecordPutDto>().IgnoreAllPropertiesWithAnInaccessibleSetter();
            CreateMap<AdminSpecificPermissionRecordRequestDto, AdminSpecificPermissionRecordEntity>().IgnoreAllPropertiesWithAnInaccessibleSetter();
            CreateMap<AdminSpecificPermissionRecordPutDto, AdminSpecificPermissionRecordEntity>().IgnoreAllPropertiesWithAnInaccessibleSetter();
            CreateMap<AdminSpecificPermissionRecordEntity, AdminSpecificPermissionRecordDto>().IgnoreAllPropertiesWithAnInaccessibleSetter();

            //新版
            CreateMap<AdminPermissionConfigRequestDto, AdminPermissionConfigEntity>().IgnoreAllPropertiesWithAnInaccessibleSetter();
            CreateMap<AdminPermissionConfigRequestDto, AdminPermissionConfigPutDto>().IgnoreAllPropertiesWithAnInaccessibleSetter();
            CreateMap<AdminPermissionConfigPutDto, AdminPermissionConfigEntity>().IgnoreAllPropertiesWithAnInaccessibleSetter();
            CreateMap<AdminPermissionConfigDto, AdminPermissionConfigEntity>().IgnoreAllPropertiesWithAnInaccessibleSetter();
            CreateMap<AdminPermissionConfigEntity, AdminPermissionConfigDto>().IgnoreAllPropertiesWithAnInaccessibleSetter();
            
            CreateMap<AdminPermissionMappingPageRequestDto, AdminPermissionMappingPagePutDto>().IgnoreAllPropertiesWithAnInaccessibleSetter();
            CreateMap<AdminPermissionMappingPageRequestDto, AdminPermissionMappingPageEntity>().IgnoreAllPropertiesWithAnInaccessibleSetter();
            CreateMap<AdminPermissionMappingPagePutDto, AdminPermissionMappingPageEntity>().IgnoreAllPropertiesWithAnInaccessibleSetter();
            CreateMap<AdminPermissionMappingPageDto, AdminPermissionMappingPageEntity>().IgnoreAllPropertiesWithAnInaccessibleSetter();
            CreateMap<AdminPermissionMappingPageEntity, AdminPermissionMappingPageDto>().IgnoreAllPropertiesWithAnInaccessibleSetter();
            CreateMap<AdminPermissionMappingPageEntity, AdminPermissionMappingPageViewDto>().IgnoreAllPropertiesWithAnInaccessibleSetter();

            CreateMap<AdminPermissionRecordRequestDto, AdminPermissionRecordEntity>().IgnoreAllPropertiesWithAnInaccessibleSetter();
            CreateMap<AdminPermissionRecordEntity, AdminPermissionRecordDto>().IgnoreAllPropertiesWithAnInaccessibleSetter();
            CreateMap<AdminPermissionRecordDto, AdminPermissionRecordEntity>().IgnoreAllPropertiesWithAnInaccessibleSetter();

            CreateMap<AdminPermissionMappingPageEntity, StaffRolePermissionPageRecordEntity>().IgnoreAllPropertiesWithAnInaccessibleSetter();
            CreateMap<StaffRolePermissionPageRecordEntity, AdminPermissionMappingPageEntity>().IgnoreAllPropertiesWithAnInaccessibleSetter();
            CreateMap<AdminPermissionMappingPageEntity, StaffRolePermissionPageRecordDto>().IgnoreAllPropertiesWithAnInaccessibleSetter();
            CreateMap<StaffRolePermissionPageRecordDto, AdminPermissionMappingPageEntity>().IgnoreAllPropertiesWithAnInaccessibleSetter();
            CreateMap<StaffRolePermissionPageRecordEntity, StaffRolePermissionPageRecordDto>().IgnoreAllPropertiesWithAnInaccessibleSetter();
            CreateMap<StaffRolePermissionPageRecordDto, StaffRolePermissionPageRecordEntity>().IgnoreAllPropertiesWithAnInaccessibleSetter();
            CreateMap<StaffRolePermissionPageRecordEntity, PageMenuDto>()
                .ForMember(p => p.Name, s => s.MapFrom(m => m.PagePathCode.Replace("/", "_").Replace("/", "_").Replace("/", "_").Replace("/", "_")))
                .ForMember(p => p.Title, s => s.MapFrom(m => m.PageName))
                .ForMember(p => p.Path, s => s.MapFrom(m => "/" + m.PagePathCode.TrimStart('/')))
                .ForMember(p => p.Icon, s => s.MapFrom(m => m.Icon))
                .ForMember(p => p.Level, s => s.MapFrom(m => m.PathLevel))
                .IgnoreAllPropertiesWithAnInaccessibleSetter();
            CreateMap<TreePermissionConfigDto, PageMenuDto>()
               .ForMember(p => p.Name, s => s.MapFrom(m => m.PagePathCode.Replace("/", "_").Replace("/", "_").Replace("/", "_").Replace("/", "_")))
               .ForMember(p => p.Title, s => s.MapFrom(m => m.PermissionName))
               .ForMember(p => p.Path, s => s.MapFrom(m => "/" + m.PagePathCode.TrimStart('/')))
               .ForMember(p => p.Icon, s => s.MapFrom(m => m.Icon))
               .ForMember(p => p.Level, s => s.MapFrom(m => m.PermissionLevel))
               .IgnoreAllPropertiesWithAnInaccessibleSetter();

        }
    }
}
